<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>攻坚任务</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/gjTask.css">
    <style>
        /*修改日期插件颜色*/
        #date-wrapper h3,
        #d-confirm {
            background: #486DE8 !important;
        }

        .load-tip {
            height: .666667rem;
            line-height: .666667rem;
            display: flex;
            justify-content: space-between;
            margin: .266667rem;
            padding: .8rem;
        }

        .load-tip p {
            width: 1.333333rem;
            height: .026667rem;
            background-color: #999999;
            margin: 10px;
            /* margin-top: .133333rem; */
        }
    </style>
</head>

<body>
    <div class="top-navigation">
        <img class="arrow" onclick="backIndex()" src="img/arrow.png" alt="图片加载中">
        <h3>攻坚任务</h3>
        <img class="search" src="img/search.png" alt="图片加载中">
    </div>
    <!-- 底部搜索界面模态框 -->
    <div class="fades" hidden></div>
    <div class="bottom-modal" hidden>
        <div class="modal-wrapper">
            <div class="modals-title">
                <p style="opacity: 0;"></p>
                <h3>条件搜索</h3>
                <h5 class="clearForm">清空</h5>
            </div>
            <form class="forms">
                <input type="text" placeholder="请输入搜索内容">
                <div class="input-container">
                    <div>
                        <h3>开始时间</h3>
                        <input name="startDate" type="text" id="startDate" placeholder="请选择开始时间"
                            data-options="{'type':'YYYY-MM-DD','beginYear':2000,'endYear':2050}">
                    </div>
                    <div>
                        <h3>结束时间</h3>
                        <input name="startDate" type="text" id="endDate" placeholder="请选择结束时间"
                            data-options="{'type':'YYYY-MM-DD','beginYear':2000,'endYear':2050}">
                    </div>
                </div>
            </form>
            <button id="search-btn">搜索</button>
        </div>
    </div>

    <!-- 底部tab页 -->
    <ul class="tab-content">
        <li class="active">待办结</li>
        <li>待审核</li>
        <li>已审核</li>
    </ul>

    <!--待办任务-->
    <div class="containers">
        <!-- <div class="report-item">
            <h3>1</h3>
            <div>
                <div class="first-row">
                    <p class="title hidden-font">嵩口人民法庭迁建18.1"…</p>
                    <p class="name">攻坚(待办结)</p>
                </div>
                <div class="second-row">
                    <p class="depart hidden-font">县委督查室 - 林淮</p>
                    <p class="date">计划结束：2019.08.24</p>
                </div>
            </div>
        </div> -->
    </div>
    <div id="load" style="display: none;">
        <div class="load-tip">
            <p></p>
            <h3>点击加载更多</h3>
            <p></p>
        </div>
    </div>


    <script src="js/flexible.js"></script>
    <script src="js/jquery-3.2.1.js"></script>
    <!-- 日期控件 -->
    <script src="js/jquery.date.js"></script>
    <!-- VConsole手机调试 -->
    <!-- <script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script> -->
    <script>
        // var vConsole = new VConsole();

        // 调用日期选择器
        $.date('#startDate');
        $.date('#endDate');

        // 跳转查看登录报表详情
        $(".login-report .report-item").click(function () {
            window.location.href = "./loginReportDetail.html"
        });


        // 显示模态框
        $(".top-navigation .search").click(function () {
            $(".bottom-modal").fadeIn();
            $(".fades").fadeIn();
        });

        // 关闭模态框
        $(".fades").click(function () {
            closeModal();
        });

        // 关闭模态框function
        function closeModal() {
            $(".bottom-modal").fadeOut();
            $(".fades").fadeOut();
        }
        // 重置form表单
        $(".clearForm").click(function () {
            $(".forms").find('input[type=text],select,input[type=hidden]').each(function () {
                $(this).val('');

            });

        });

        // 提交表单
        $("#search-btn").click(function () {
            var data = $(".forms").serialize();
            console.log(data);
            closeModal();
        });
    </script>
    <script>
        $(function () {
            // 切换tab
            $(".tab-content").on("click", "li", function () {
                $("#load").css("display", "none");
                $(this).addClass("active").siblings().removeClass("active");
                var text = $(this).text();
                if (text === "待办结") {
                    tackFlag = "1";
                } else if (text === "待审核") {
                    tackFlag = "2";
                } else if (text === "已审核") {
                    tackFlag = "3";
                }
                num = 0;
                page = 1;
                $(".containers").empty();
                loadContent();
            });

            // 获取用户电话号码
            var userPhone = window.AndroidWebView.getUserId();
            var page = 1; //页数
            var num = 0; //序号
            var tackFlag = "1";
            loadContent();

            function loadContent() {
                $.ajax({
                    url: "http://120.78.158.120:8099/zhApp/taskToTack/lists",
                    type: "POST",
                    dataType: "json", //返回数据形式为json
                    contentType: 'application/json;charset=UTF-8',
                    data: JSON.stringify({
                        "userPhone": userPhone,
                        "tackFlag": tackFlag,
                        "paging": {
                            "currentPage": page
                        }
                    }),
                    success: function (res) {
                        console.log(res);
                        if (res.code === "200" && res.data !== undefined) {
                            $("#load").css("display", "block");
                            var item = res.data;
                            var html = "";
                            for (var i = 0; i < item.length; i++) {
                                num++
                                html = '\
                            <div class="report-item">\
                                <h3>' + num + '</h3>\
                                <div>\
                                    <div class="first-row">\
                                        <p class="title hidden-font">' + item[i].taskName + '</p>\
                                        <p class="name">' + (item[i].tackFlag === "1" ? "待办结" : item[i].tackFlag ===
                                        "2" ? "待审核" : item[i].tackFlag === "3" ? "已审核" : "") + '</p>\
                                    </div>\
                                    <div class="second-row">\
                                        <p class="depart hidden-font">' + item[i].groupType + ' - ' + item[i]
                                    .inspectors + '</p>\
                                        <p class="date">计划结束：' + item[i].planEndDate + '</p>\
                                    </div>\
                                </div>\
                            </div>\
                            ';
                                $(".containers").append(html);
                            }

                        }

                        if (res.data !== undefined) {

                            $(".load-tip h3").html("点击加载更多");
                        } else {
                            $(".load-tip h3").html("数据已加载完毕");
                        }
                    }
                });
            }

            $(".load-tip").click(function () {
                page++
                console.log(page);
                $(".load-tip h3").html("数据正在加载中");
                loadContent();
            });
        });

        // 返回安卓首页
        function backIndex() {
            window.AndroidWebView.showInfoFromJs()
        }
    </script>
</body>

</html>